#ifndef MANEJADORBITS_H_
#define MANEJADORBITS_H_

#include <string>

using namespace std;

namespace Toolkit
{

class ManejadorBits
{

public:

	ManejadorBits();
	virtual ~ManejadorBits();

	string getEmision();
	void procesar(unsigned int &techo, unsigned int &piso);

	unsigned int compactarVentana(unsigned int &ventana);

	void reset();

private:

	bool estaOverflow(const unsigned int &techo, const unsigned int &piso) const;
	bool estaUnderflow(const unsigned int &techo, const unsigned int &piso) const;
	void manejarOverflow(unsigned int &techo, unsigned int &piso);
	void manejarUnderflow(unsigned int &techo, unsigned int &piso);

	void negarRangoBits(unsigned int &numero, const unsigned int &posicionInicial,
				        const unsigned int &posicionFinal) const;
	void emitir(const unsigned int &numero, const unsigned int &cantidadOverflow);
	void agregarPadding();

	unsigned int contadorOverflow;
	unsigned int contadorUnderflow;
	unsigned int ufEmisionesVacias;
	string emision;
};

}

#endif /* MANEJADORBITS_H_ */
